package com.hall.service;

import com.hall.dao.CommentMapper;
import com.hall.pojo.CommentData;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;
@Service
public class CommentServiceImpl implements CommentService{
    @Autowired
    CommentMapper commentMapper;
    @Override
    public void saveComment(CommentData commentData) {
        String id=UUID.randomUUID().toString().replaceAll("-", "");
        commentData.setId(id);
        commentMapper.insert(commentData);
    }

    @Override
    public void deleteComment(CommentData commentData) {
     commentMapper.delete(commentData);
    }

    @Override
    public CommentData findCommentById(@Param(value = "id") String id) {
        return commentMapper.get(id);
    }

    @Override
    public List<CommentData> findCommentList(CommentData commentData) {
        return commentMapper.findList(commentData);
    }

    public  void  updateComment(CommentData commentData){
       commentMapper.update(commentData);
    }

    public void setCommentMapper(CommentMapper commentMapper) {
    }
}
